﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;

namespace ZDSoft.TES.Entity.SystemEntity
{
    [ActiveRecord("SystemFunction")]
    public class SystemFunction : EntityBase<SystemFunction>
    {
        /// <summary>
        /// 系统功能名称
        /// </summary>
        [Property]
        public string SystemFunctionName { get; set; }

        /// <summary>
        /// 控制器名
        /// </summary>
        [Property]
        public string ControllerName { get; set; }

        /// <summary>
        /// 方法名
        /// </summary>
        [Property]
        public string ActionName { get; set; }

        /// <summary>
        /// 功能类名
        /// </summary>
        [Property]
        public string ClassName { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Property]
        public bool IsActive { get; set; }

        /// <summary>
        /// 父级菜单
        /// </summary>
        [BelongsTo("PartentID", Lazy = FetchWhen.OnInvoke)]
        public SystemFunction Parent { get; set; }

        /// <summary>
        /// 子级菜单
        /// </summary>
        [HasMany(typeof(SystemFunction), ColumnKey = "PartentID", Lazy = true)]
        public IList<SystemFunction> Children { get; set; }

        [HasAndBelongsToMany(typeof(Role), Table = "SystemRoleFunction", ColumnKey = "SystemFunctionID", ColumnRef = "RoleID", Lazy = true)]
        public IList<Role> Roles { get; set; }
    }
}
